home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / hity wydania / Ubuntu 9.10 PL / karmelkowy-koliberek-desktop-9.10-i386-PL.iso / casper / filesystem.squashfs / usr / share / hplip / base / pml.py < prev    next >
Text File  |  2009-10-09  |  27KB  |  781 lines

  1. # -*- coding: utf-8 -*-
  2. #
  3. # (c) Copyright 2003-2007 Hewlett-Packard Development Company, L.P.
  4. #
  5. # This program is free software; you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation; either version 2 of the License, or
  8. # (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  18. #
  19. # Author: Don Welch
  20. #
  21.  
  22. # Std Lib
  23. import sys
  24. import struct
  25.  
  26. # Local
  27. from g import *
  28. from base.utils import unprintable
  29.  
  30. # Request codes
  31. GET_REQUEST = 0x00
  32. GET_NEXT_REQUEST = 0x01
  33. GET_BLOCK_REQUEST = 0x02
  34. GET_NEXT_BLOCK_REQUEST = 0x03
  35. SET_REQUEST = 0x04
  36. ENABLE_TRAP_REQUEST = 0x05
  37. DISABLE_TRAP_REQUEST = 0x06
  38. TRAP_REQUEST = 0x07
  39.  
  40. # Reply codes
  41. GET_REPLY = 0x80
  42. GET_NEXT_REPLY = 0x81
  43. BLOCK_REPLY = 0x82
  44. NEXT_BLOCK_REPLY = 0x83
  45. SET_REPLY = 0x84
  46. ENABLE_TRAP_REPLY = 0x85
  47. DISABLE_TRAP_REPLY = 0x85
  48.  
  49. # PML Reply error codes
  50. ERROR_OK = 0x00
  51. ERROR_OK_END_OF_SUPPORTED_OBJECTS = 0x01
  52. ERROR_OK_NEAREST_LEGAL_VALUE_SUBSITUTED = 0x02
  53. ERROR_MAX_OK = 0x7f
  54. ERROR_UNKNOWN_REQUEST = 0x80
  55. ERROR_BUFFER_OVERFLOW = 0x81
  56. ERROR_COMMAND_EXECUTION = 0x82
  57. ERROR_UNKNOWN_OID = 0x83
  58. ERROR_OBJ_DOES_NOT_SUPPORT_SPECIFIED_ACTION = 0x84
  59. ERROR_INVALID_OR_UNSUPPORTED_VALUE = 0x85
  60. ERROR_PAST_END_OF_SUPPORTED_OBJS = 0x86
  61. ERROR_ACTION_CANNOT_BE_PERFORMED_NOW = 0x87
  62. ERROR_SYNTAX = 0x88
  63.  
  64. # Data types
  65. TYPE_MASK = 0xfc
  66. TYPE_OBJECT_IDENTIFIER = 0x00
  67. TYPE_ENUMERATION = 0x04
  68. TYPE_SIGNED_INTEGER = 0x08
  69. TYPE_REAL = 0x0C
  70. TYPE_STRING = 0x10
  71. TYPE_BINARY = 0x14
  72. TYPE_ERROR_CODE = 0x18
  73. TYPE_NULL_VALUE = 0x1c
  74. TYPE_COLLECTION = 0x20
  75. TYPE_UNKNOWN = 0xff
  76.  
  77. # Misc. constants
  78. MAX_VALUE_LEN = 1023
  79. MAX_OID_LEN = 32
  80. MAX_DATALEN = 4096
  81.  
  82. # desired_int_sizes
  83. INT_SIZE_BYTE = struct.calcsize('b')
  84. INT_SIZE_WORD = struct.calcsize('h')
  85. INT_SIZE_INT = struct.calcsize('i')
  86.  
  87.  
  88. def buildPMLGetPacket(oid): # String dotted notation
  89.     oid = ''.join([chr(int(b.strip())) for b in oid.split('.')])
  90.     return struct.pack('>BBB%ss' % len(oid),
  91.                         GET_REQUEST,
  92.                         TYPE_OBJECT_IDENTIFIER,
  93.                         len(oid), oid)
  94.  
  95. def buildPMLGetPacketEx(oid): # OID identifier dict
  96.     return buildPMLGetPacket(oid['oid'])
  97.  
  98. def buildEmbeddedPMLSetPacket(oid, value, data_type):
  99.     return ''.join(['PML\x20', buildPMLSetPacket(oid, value, data_type)])
  100.  
  101. def buildPMLSetPacket(oid, value, data_type): # String dotted notation
  102.     oid = ''.join([chr(int(b.strip())) for b in oid.split('.')])
  103.  
  104.     if data_type in (TYPE_ENUMERATION, TYPE_SIGNED_INTEGER, TYPE_COLLECTION):
  105.         data = struct.pack(">i", int(value))
  106.  
  107.         if value > 0:
  108.             while len(data) > 0 and data[0] == '\x00':
  109.                 data = data[1:]
  110.         else:
  111.             while len(data) > 1 and data[0] == '\xff' and data[1] == '\xff':
  112.                 data = data[1:]
  113.  
  114.         data = struct.pack(">BB%ds" % len(data), data_type, len(data), data)
  115.  
  116.     elif data_type == TYPE_REAL:
  117.         data = struct.pack(">BBf", data_type, struct.calcsize("f"), float(value))
  118.  
  119.     elif data_type == TYPE_STRING:
  120.         data = struct.pack(">BBBB%ss" % len(value), data_type, len(value) + 2, 0x01, 0x15, value)
  121.  
  122.     elif data_type == TYPE_BINARY:
  123.         data = struct.pack(">BB%ss" % len(value), data_type, len(value), ''.join([chr(x) for x in value]))
  124.  
  125.     p = struct.pack('>BBB%ss%ss' % (len(oid), len(data)),
  126.                     SET_REQUEST,
  127.                     TYPE_OBJECT_IDENTIFIER,
  128.                     len(oid), oid,
  129.                     data)
  130.  
  131.     return p
  132.  
  133. def ConvertToPMLDataFormat(value, data_type):
  134.     if data_type in (TYPE_ENUMERATION, TYPE_SIGNED_INTEGER, TYPE_COLLECTION):
  135.         data = struct.pack(">i", int(value))
  136.  
  137.         if value > 0:
  138.             while len(data) > 0 and data[0] == '\x00':
  139.                 data = data[1:]
  140.         else:
  141.             while len(data) > 1 and data[0] == '\xff' and data[1] == '\xff':
  142.                 data = data[1:]
  143.  
  144.         data = struct.pack(">%ds" % len(data), data)
  145.  
  146.     elif data_type == TYPE_REAL:
  147.         data = struct.pack(">f", float(value))
  148.  
  149.     elif data_type == TYPE_STRING:
  150.         #data = struct.pack(">BB%ss" % len(value), 0x01, 0x15, value)
  151.         data = struct.pack(">BB%ss" % len(value), 0x00, 0x0e, value) # changed for K80, seems to work on others...
  152.  
  153.     elif data_type == TYPE_BINARY:
  154.         if type(value) == type(''):
  155.             data = value
  156.         elif type(value) == type([]):
  157.             data = struct.pack(">%ds" % len(value), ''.join([chr(x) for x in value]))
  158.         else:
  159.             log.error("Value type error.")
  160.  
  161.     return data
  162.  
  163. def ConvertFromPMLDataFormat(data, data_type, desired_int_size=INT_SIZE_INT):
  164.     if data_type in (TYPE_ENUMERATION, TYPE_SIGNED_INTEGER, TYPE_COLLECTION):
  165.  
  166.         if len(data):
  167.  
  168.             if data[0] == '\xff':
  169.                 while len(data) < 4:
  170.                     data = '\xff' + data
  171.  
  172.             else:
  173.                 while len(data) < 4:
  174.                     data = '\x00' + data
  175.  
  176.             if desired_int_size == INT_SIZE_INT:
  177.                 return struct.unpack(">i", data)[0]
  178.  
  179.             elif desired_int_size == INT_SIZE_WORD:
  180.                 return struct.unpack(">h", data[-INT_SIZE_WORD])[0]
  181.  
  182.             elif desired_int_size == INT_SIZE_BYTE:
  183.                 return struct.unpack(">b", data[-INT_SIZE_BYTE])[0]
  184.  
  185.             else:
  186.                 raise Error(ERROR_INTERNAL)
  187.  
  188.         else:
  189.             return 0
  190.  
  191.     elif data_type == TYPE_REAL:
  192.         if len(data) == struct.calcsize("f"):
  193.             return struct.unpack(">f", data)[0]
  194.         else:
  195.             return 0.0
  196.  
  197.     elif data_type == TYPE_STRING:
  198.         return ''.join([c for c in data if c not in unprintable])
  199.  
  200.     elif data_type == TYPE_BINARY:
  201.         return data
  202.  
  203.     return None
  204.  
  205.  
  206. def parsePMLPacket(p, expected_data_type=TYPE_UNKNOWN):
  207.     pos, state = 0, 1
  208.  
  209.     data_type = TYPE_UNKNOWN
  210.     error_state = False
  211.     while state:
  212.  
  213.         if state == 1: # reply and error code
  214.             reply, error_code = struct.unpack(">BB", p[pos : pos + 2])
  215.             state, pos = 2, pos + 2
  216.  
  217.             if error_code > ERROR_MAX_OK:
  218.                 error_state = True
  219.  
  220.         elif state == 2: # data type and length
  221.             data_type, length = struct.unpack(">BB", p[pos : pos + 2])
  222.             state, pos = 3, pos + 2
  223.  
  224.             if error_state:
  225.  
  226.                 if expected_data_type in (TYPE_COLLECTION, TYPE_ENUMERATION,
  227.                                     TYPE_SIGNED_INTEGER, TYPE_BINARY):
  228.                     data = 0
  229.  
  230.                 elif expected_data_type == TYPE_REAL:
  231.                     data = 0.0
  232.  
  233.                 else:
  234.                     data = ''
  235.  
  236.                 break
  237.  
  238.         elif state == 3: # data
  239.             data = p[pos : pos + length]
  240.             state, pos = 0, pos + length
  241.  
  242.             if data_type == TYPE_OBJECT_IDENTIFIER:
  243.                 state = 2
  244.                 continue
  245.  
  246.             elif data_type == TYPE_STRING:
  247.                 if length > 0:
  248.                     symbol_set, data = struct.unpack(">H%ss" % (length - 2), data)
  249.                 else:
  250.                     data = ''
  251.  
  252.             elif data_type == TYPE_BINARY:
  253.                 data = [ord(b) for b in data]
  254.  
  255.             elif data_type == TYPE_ENUMERATION:
  256.                 if length > 0:
  257.                     data = struct.unpack(">i", "%s%s" % ('\x00' * (4 - length), data))[0]
  258.                 else:
  259.                     data = 0
  260.  
  261.             elif data_type == TYPE_REAL:
  262.                 if length > 0:
  263.                     data = struct.unpack(">f", data)[0]
  264.                 else:
  265.                     data = 0.0
  266.  
  267.             elif data_type ==  TYPE_SIGNED_INTEGER:
  268.                 if length > 0:
  269.                     pad = '\x00'
  270.                     if ord(data[0]) & 0x80: pad = '\xff' # negative number
  271.                     data = struct.unpack(">i", "%s%s" % (pad * (4 - length), data))[0]
  272.                 else:
  273.                     data = 0
  274.  
  275.             elif data_type == TYPE_COLLECTION:
  276.                 if length > 0:
  277.                     data = struct.unpack(">i", "%s%s" % ('\x00' * (4 - length), data))[0]
  278.                 else:
  279.                     data = 0
  280.  
  281.             elif data_type == TYPE_ERROR_CODE:
  282.                 data = struct.unpack(">B", data)[0]
  283.  
  284.             elif data_type == TYPE_NULL_VALUE:
  285.                 data = None
  286.  
  287.             break
  288.  
  289.     return data, data_type, error_code
  290.  
  291.  
  292.  
  293. def HPToSNMP(oid): # 1.
  294.     return '.'.join(['1.3.6.1.4.1.11.2.3.9.4.2', oid, '0'])
  295.  
  296. def StdToSNMP(oid): # 2.
  297.     return '.'.join(['1.3.6.1.2.1.43', oid[2:]])
  298.  
  299. def HRToSNMP(oid): # 3.
  300.     return '.'.join(['1.3.6.1.2.1.25', oid[2:]])
  301.  
  302. def PMLToSNMP(oid):
  303.     assert len(oid) > 2
  304.  
  305.     if oid[0] == '0': # 0. means its already in SNMP format (will fail for PML)
  306.         return oid[2:]
  307.  
  308.     elif oid[0] == '1': # HP MIB
  309.         return HPToSNMP(oid)
  310.  
  311.     elif oid[0] == '2': # Std MIB
  312.         return StdToSNMP(oid)
  313.  
  314.     elif oid[0] == '3': # Host Resources MIB
  315.         return HRToSNMP(oid)
  316.  
  317.     assert False
  318.  
  319.  
  320. #
  321. # OIDs
  322. #
  323.  
  324. OID_DEVICE_ID = ('0.1.3.6.1.4.1.11.2.3.9.1.1.7.0', TYPE_STRING) # network/SNMP only (undocumented)
  325.  
  326. OID_DEVICE_SUPPORTED_FUNCTIONS = ('1.1.2.67', TYPE_COLLECTION)
  327. DEVICE_SUPPORTED_FUNCTIONS_SCAN =                 0x00002
  328. DEVICE_SUPPORTED_FUNCTIONS_SCAN_SIMPLEX =         0x00004
  329. DEVICE_SUPPORTED_FUNCTIONS_SCAN_DUPLEX =          0x00008
  330. DEVICE_SUPPORTED_FUNCTIONS_COPY =                 0x00010
  331. DEVICE_SUPPORTED_FUNCTIONS_COPY_SIMPLEX_SIMPLEX = 0x00020
  332. DEVICE_SUPPORTED_FUNCTIONS_COPY_SIMPLEX_DUPLEX =  0x00040
  333. DEVICE_SUPPORTED_FUNCTIONS_COPY_DUPLEX_SIMPLEX =  0x00080
  334. DEVICE_SUPPORTED_FUNCTIONS_COPY_DUPLEX_DUPLEX =   0x00100
  335. DEVICE_SUPPORTED_FUNCTIONS_COPY_COLLATION =       0x00200
  336. DEVICE_SUPPORTED_FUNCTIONS_PRINT =                0x00400
  337. DEVICE_SUPPORTED_FUNCTIONS_AUTO_FEED_SIMPLEX =    0x00800
  338. DEVICE_SUPPORTED_FUNCTIONS_AUTO_FEED_DUPLEX =     0x01000
  339. DEVICE_SUPPORTED_FUNCTIONS_FAX_SEND =             0x02000
  340. DEVICE_SUPPORTED_FUNCTIONS_FAX_RECV =             0x04000
  341. DEVICE_SUPPORTED_FUNCTIONS_MASS_STORAGE =         0x08000
  342. DEVICE_SUPPORTED_FUNCTIONS_STREAMING_SAVE =       0x10000
  343. DEVICE_SUPPORTED_FUNCTIONS_FAX_CONFIG =           0x20000
  344. DEVICE_SUPPORTED_FUNCTIONS_FAX_CFG_SPEEDDIAL =    0x40000
  345. DEVICE_SUPPORTED_FUNCTIONS_FAX_CFG_GROUPDIAL =    0x80000
  346.  
  347. OID_CLEAN = ('1.4.1.5.1.1', TYPE_ENUMERATION)
  348. CLEAN_CLEAN = 100
  349. CLEAN_PRIME = 200
  350. CLEAN_WIPE_AND_SPIT = 300
  351.  
  352. OID_SERIAL_NUMBER = ('1.1.3.3', TYPE_STRING)
  353. OID_R_SETTING = ('1.1.1.35', TYPE_SIGNED_INTEGER)
  354.  
  355. OID_PRINT_INTERNAL_PAGE = ('1.1.5.2', TYPE_ENUMERATION)
  356. PRINT_INTERNAL_PAGE_SUPPLIES_PAGE = 101
  357. PRINT_INTERNAL_PAGE_COLOR_PALETTE_CMYK_PAGE = 259
  358. PRINT_INTERNAL_PAGE_COLOR_CAL = 1102
  359. PRINT_INTERNAL_PAGE_COLOR_CAL_VERIFICATION = 1104
  360. PRINT_INTERNAL_PAGE_ALIGNMENT_PAGE = 1100 # LBOW/OJ Pro L7xxx
  361. PRINT_INTERNAL_PAGE_ALIGNMENT_PAGE_VERIFICATION = 1150 # LBOW
  362. PRINT_INTERNAL_PAGE_LINEFEED_CALIBRATION = 1407 # OJ Pro
  363. PRINT_INTERNAL_PAGE_AUTOMATIC_COLOR_CALIBRATION = 1408 # PS Pro B8800
  364. PRINT_INTERNAL_PAGE_PRINT_QUALITY_DIAGNOSTIC = 1409 # OJ Pro
  365.  
  366. # From xojpanel
  367. OID_SPM_LINE1 = ('2.16.5.1.2.1.1', TYPE_STRING)
  368. OID_SPM_LINE2 = ('2.16.5.1.2.1.2', TYPE_STRING)
  369.  
  370. OID_HP_LINE1 = ('1.1.2.20.2.1.1', TYPE_STRING)
  371. OID_HP_LINE2 = ('1.1.2.20.2.2.1', TYPE_STRING)
  372.  
  373.  
  374. # LaserJet Status (status type 3)
  375. OID_ON_OFF_LINE = ('1.1.2.5', TYPE_SIGNED_INTEGER)
  376. ON_OFF_LINE_ONLINE = 1
  377. ON_OFF_LINE_OFFLINE = 2
  378. ON_OFF_LINE_OFFLINE_AT_END_OF_JOB = 3
  379.  
  380. OID_SLEEP_MODE = ('1.1.1.2', TYPE_SIGNED_INTEGER)
  381. SLEEP_MODE_FALSE = 1
  382. SLEEP_MODE_TRUE = 2
  383.  
  384. OID_PRINTER_STATUS = ('3.3.5.1.1.1', TYPE_SIGNED_INTEGER)
  385. PRINTER_STATUS_OTHER = 1
  386. PRINTER_STATUS_UNKNOWN = 2
  387. PRINTER_STATUS_IDLE = 3
  388. PRINTER_STATUS_PRINTING = 4
  389. PRINTER_STATUS_WARMUP = 5
  390.  
  391. OID_COVER_STATUS = ('2.6.1.1.3.1.1', TYPE_SIGNED_INTEGER)
  392. COVER_STATUS_OPEN = 3
  393. COVER_STATUS_CLOSED = 4
  394.  
  395. OID_DETECTED_ERROR_STATE = ('3.3.5.1.2.1', TYPE_BINARY)
  396. DETECTED_ERROR_STATE_LOW_PAPER_MASK = 0x80
  397. DETECTED_ERROR_STATE_NO_PAPER_MASK = 0x40
  398. DETECTED_ERROR_STATE_LOW_CART_MASK = 0x20
  399. DETECTED_ERROR_STATE_OUT_CART_MASK = 0x10
  400. DETECTED_ERROR_STATE_DOOR_OPEN_MASK = 0x08
  401. DETECTED_ERROR_STATE_JAMMED_MASK = 0x04
  402. DETECTED_ERROR_STATE_OFFLINE_MASK = 0x02
  403. DETECTED_ERROR_STATE_SERVICE_REQUEST_MASK = 0x01
  404. DETECTED_ERROR_STATE_NO_ERROR = 0x00
  405.  
  406. OID_MARKER_SUPPLIES_TYPE_x = '2.11.1.1.5.1.%d'
  407. OID_MARKER_SUPPLIES_TYPE_x_TYPE = TYPE_ENUMERATION
  408. OID_MARKER_SUPPLIES_TYPE_OTHER = 1
  409. OID_MARKER_SUPPLIES_TYPE_UNKNOWN = 2
  410. OID_MARKER_SUPPLIES_TYPE_TONER = 3
  411. OID_MARKER_SUPPLIES_TYPE_WASTE_TONER = 4
  412. OID_MARKER_SUPPLIES_TYPE_INK = 5
  413. OID_MARKER_SUPPLIES_TYPE_INK_CART = 6
  414. OID_MARKER_SUPPLIES_TYPE_INK_RIBBON = 7
  415. OID_MARKER_SUPPLIES_TYPE_WASTE_INK = 8
  416. OID_MARKER_SUPPLIES_TYPE_OPC = 9
  417. OID_MARKER_SUPPLIES_TYPE_DEVELOPER = 10
  418. OID_MARKER_SUPPLIES_TYPE_FUSER_OIL = 11
  419. OID_MARKER_SUPPLIES_TYPE_SOLID_WAX = 12
  420. OID_MARKER_SUPPLIES_TYPE_RIBBON_WAX = 13
  421. OID_MARKER_SUPPLIES_TYPE_WASTE_WAX = 14
  422. OID_MARKER_SUPPLIES_TYPE_FUSER = 15
  423. OID_MARKER_SUPPLIES_TYPE_CORONA_WIRE = 16
  424. OID_MARKER_SUPPLIES_TYPE_FUSER_OIL_WICK = 17
  425. OID_MARKER_SUPPLIES_TYPE_CLEANER_UNIT = 18
  426. OID_MARKER_SUPPLIES_TYPE_FUSER_CLEANING_PAD = 19
  427. OID_MARKER_SUPPLIES_TYPE_TRANSFER_UNIT = 20
  428. OID_MARKER_SUPPLIES_TYPE_TONER_CART = 21
  429. OID_MARKER_SUPPLIES_TYPE_FUSER_OILER = 22
  430. OID_MARKER_SUPPLIES_TYPE_ADF_MAINT_KIT = 23
  431.  
  432. OID_MARKER_SUPPLIES_COLORANT_INDEX_x = '2.11.1.1.3.1.%d'
  433. OID_MARKER_SUPPLIES_COLORANT_INDEX_x_TYPE = TYPE_SIGNED_INTEGER
  434.  
  435. OID_MARKER_SUPPLIES_MAX_x = '2.11.1.1.8.1.%d'
  436. OID_MARKER_SUPPLIES_MAX_x_TYPE = TYPE_SIGNED_INTEGER
  437.  
  438. OID_MARKER_SUPPLIES_LEVEL_x = '2.11.1.1.9.1.%d'
  439. OID_MARKER_SUPPLIES_LEVEL_x_TYPE = TYPE_SIGNED_INTEGER
  440.  
  441. OID_MARKER_COLORANT_VALUE_x = '2.12.1.1.4.1.%d'
  442. OID_MARKER_COLORANT_VALUE_x_TYPE = TYPE_STRING
  443.  
  444. OID_MARKER_STATUS_x = '2.10.2.1.15.1.%d'
  445. OID_MARKER_STATUS_x_TYPE = TYPE_SIGNED_INTEGER
  446. OID_MARKER_STATUS_OK = 0
  447. OID_MARKER_STATUS_LOW_TONER_CONT = 8
  448. OID_MARKER_STATUS_LOW_TONER_STOP = 49
  449. OID_MARKER_STATUS_MISINSTALLED = 51
  450.  
  451. OID_MARKER_SUPPLIES_DESCRIPTION_x = '2.11.1.1.6.1.%d'
  452. OID_MARKER_SUPPLIES_DESCRIPTION_x_TYPE = TYPE_BINARY
  453.  
  454. OID_DEVICE_STATUS = ('3.3.2.1.5.1', TYPE_ENUMERATION)
  455. DEVICE_STATUS_UNKNOWN = 1
  456. DEVICE_STATUS_RUNNING = 2
  457. DEVICE_STATUS_WARNING = 3
  458. DEVICE_STATUS_TESTING = 4
  459. DEVICE_STATUS_DOWN = 5
  460. #end
  461.  
  462. # alignment, cleaning, etc.
  463. OID_AUTO_ALIGNMENT = ('1.1.5.2', TYPE_ENUMERATION)
  464. AUTO_ALIGNMENT = 1100
  465. OID_ZCA = ('1.4.1.8.5.4.1', TYPE_SIGNED_INTEGER)
  466. OID_AGENT2_VERTICAL_ALIGNMENT = ('1.4.1.5.3.2.5', TYPE_SIGNED_INTEGER)
  467. OID_AGENT2_HORIZONTAL_ALIGNMENT = ('1.4.1.5.3.2.6', TYPE_SIGNED_INTEGER)
  468. OID_AGENT1_BIDIR_ADJUSTMENT = ('1.4.1.5.3.1.7', TYPE_SIGNED_INTEGER)
  469. OID_AGENT2_BIDIR_ADJUSTMENT = ('1.4.1.5.3.2.7', TYPE_SIGNED_INTEGER)
  470. OID_MARKING_AGENTS_INITIALIZED = ('1.4.1.5.1.4', TYPE_COLLECTION)
  471. OID_AGENT3_VERTICAL_ALIGNMENT = ("1.4.1.5.3.3.5", TYPE_SIGNED_INTEGER)
  472. OID_AGENT3_HORIZONTAL_ALIGNMENT = ("1.4.1.5.3.3.6", TYPE_SIGNED_INTEGER)
  473. OID_AGENT3_BIDIR_ADJUSTMENT = ("1.4.1.5.3.3.7", TYPE_SIGNED_INTEGER)
  474. OID_COLOR_CALIBRATION_SELECTION = ("1.4.1.5.1.9", TYPE_SIGNED_INTEGER)
  475.  
  476. # Type 4 color cal
  477. OID_COLOR_CALIBRATION_ARRAY_1 = ("1.4.1.1.30.1.1", TYPE_SIGNED_INTEGER) # K
  478. OID_COLOR_CALIBRATION_ARRAY_2 = ("1.4.1.1.30.1.2", TYPE_SIGNED_INTEGER) # C
  479. OID_COLOR_CALIBRATION_ARRAY_3 = ("1.4.1.1.30.1.3", TYPE_SIGNED_INTEGER) # M
  480. OID_COLOR_CALIBRATION_ARRAY_4 = ("1.4.1.1.30.1.4", TYPE_SIGNED_INTEGER) # Y
  481. OID_COLOR_CALIBRATION_ARRAY_5 = ("1.4.1.1.30.1.5", TYPE_SIGNED_INTEGER) # c
  482. OID_COLOR_CALIBRATION_ARRAY_6 = ("1.4.1.1.30.1.6", TYPE_SIGNED_INTEGER) # m
  483.  
  484. # Supported funcs
  485. OID_DEVICE_SUPPORTED_FUNCTIONS = ('1.1.2.67', TYPE_COLLECTION)
  486. DEVICE_SUPPORTED_FUNCTIONS_SCAN =                 0x00002
  487. DEVICE_SUPPORTED_FUNCTIONS_SCAN_SIMPLEX =         0x00004
  488. DEVICE_SUPPORTED_FUNCTIONS_SCAN_DUPLEX =          0x00008
  489. DEVICE_SUPPORTED_FUNCTIONS_COPY =                 0x00010
  490. DEVICE_SUPPORTED_FUNCTIONS_COPY_SIMPLEX_SIMPLEX = 0x00020
  491. DEVICE_SUPPORTED_FUNCTIONS_COPY_SIMPLEX_DUPLEX =  0x00040
  492. DEVICE_SUPPORTED_FUNCTIONS_COPY_DUPLEX_SIMPLEX =  0x00080
  493. DEVICE_SUPPORTED_FUNCTIONS_COPY_DUPLEX_DUPLEX =   0x00100
  494. DEVICE_SUPPORTED_FUNCTIONS_COPY_COLLATION =       0x00200
  495. DEVICE_SUPPORTED_FUNCTIONS_PRINT =                0x00400
  496. DEVICE_SUPPORTED_FUNCTIONS_AUTO_FEED_SIMPLEX =    0x00800
  497. DEVICE_SUPPORTED_FUNCTIONS_AUTO_FEED_DUPLEX =     0x01000
  498. DEVICE_SUPPORTED_FUNCTIONS_FAX_SEND =             0x02000
  499. DEVICE_SUPPORTED_FUNCTIONS_FAX_RECV =             0x04000
  500. DEVICE_SUPPORTED_FUNCTIONS_MASS_STORAGE =         0x08000
  501. DEVICE_SUPPORTED_FUNCTIONS_STREAMING_SAVE =       0x10000
  502. DEVICE_SUPPORTED_FUNCTIONS_FAX_CONFIG =           0x20000
  503. DEVICE_SUPPORTED_FUNCTIONS_FAX_CFG_SPEEDDIAL =    0x40000
  504. DEVICE_SUPPORTED_FUNCTIONS_FAX_CFG_GROUPDIAL =    0x80000
  505.  
  506.  
  507. OID_BATTERY_LEVEL = ('1.1.2.13', TYPE_SIGNED_INTEGER)
  508. OID_POWER_MODE = ('1.1.2.14', TYPE_ENUMERATION)
  509. POWER_MODE_ADPATER = 0x01
  510. POWER_MODE_BATTERY = 0x02
  511. POWER_MODE_CHARGING = 0x04
  512. POWER_MODE_DISCHARGING = 0x08
  513. POWER_MODE_BATTERY_LEVEL_KNOWN = 0x10
  514.  
  515. OID_BATTERY_LEVEL_2 = ('1.1.2.61', TYPE_SIGNED_INTEGER)
  516.  
  517. OID_POWER_SETTINGS = ('1.1.2.118', TYPE_ENUMERATION)
  518. OID_POWER_SETTINGS_15MIN = 1
  519. OID_POWER_SETTINGS_30MIN = 2
  520. OID_POWER_SETTINGS_45MIN = 3
  521. OID_POWER_SETTINGS_1HR = 4
  522. OID_POWER_SETTINGS_2HR = 5
  523. OID_POWER_SETTINGS_3HR = 6
  524. OID_POWER_SETTINGS_NEVER = 999
  525.  
  526. #
  527. # Fax
  528. #
  529.  
  530. OID_DEV_DOWNLOAD_TIMEOUT = ('1.1.1.17', TYPE_SIGNED_INTEGER)
  531. DEFAULT_DOWNLOAD_TIMEOUT = 600
  532.  
  533. OID_FAX_DOWNLOAD_ERROR = ('1.3.7.2.6', TYPE_SIGNED_INTEGER)
  534.  
  535. OID_FAXJOB_TX_TYPE = ('1.1.6.3.1.3', TYPE_ENUMERATION)
  536. FAXJOB_TX_TYPE_HOST_ONLY = 2
  537.  
  538. OID_FAXJOB_TX_STATUS = ('1.1.6.3.3.3.1', TYPE_ENUMERATION)
  539. FAXJOB_TX_STATUS_IDLE = 1
  540. FAXJOB_TX_STATUS_DIALING = 2
  541. FAXJOB_TX_STATUS_CONNECTING = 3
  542. FAXJOB_TX_STATUS_TRANSMITTING = 4
  543. FAXJOB_TX_STATUS_DONE = 5
  544.  
  545. FAXJOB_TX_STATUS_STR = {FAXJOB_TX_STATUS_IDLE: "Idle",
  546.                  FAXJOB_TX_STATUS_DIALING: "Dialing",
  547.                  FAXJOB_TX_STATUS_CONNECTING: "Connecting",
  548.                  FAXJOB_TX_STATUS_TRANSMITTING: "Transmitting",
  549.                  FAXJOB_TX_STATUS_DONE: "Done",}
  550.  
  551. OID_FAXJOB_RX_STATUS = ('1.1.6.3.3.1.1', TYPE_ENUMERATION)
  552. FAXJOB_RX_STATUS_IDLE = 1
  553. FAXJOB_RX_STATUS_RINGING = 2
  554. FAXJOB_RX_STATUS_ANSWERING = 3
  555. FAXJOB_RX_STATUS_RECEIVING = 4
  556. FAXJOB_RX_STATUS_DONE = 5
  557.  
  558. FAXJOB_RX_STATUS_STR = {FAXJOB_RX_STATUS_IDLE: "Idle",
  559.                         FAXJOB_RX_STATUS_RINGING: "Ringing",
  560.                         FAXJOB_RX_STATUS_ANSWERING: "Answering",
  561.                         FAXJOB_RX_STATUS_RECEIVING: "Receiving",
  562.                         FAXJOB_RX_STATUS_DONE: "Done",}
  563.  
  564. OID_FAX_DOWNLOAD = ('1.3.7.1.6', TYPE_ENUMERATION)
  565. UPDN_STATE_IDLE = 1
  566. UPDN_STATE_REQSTART = 2
  567. UPDN_STATE_XFERACTIVE = 3
  568. UPDN_STATE_ERRORABORT = 4
  569. UPDN_STATE_XFERDONE = 5
  570. UPDN_STATE_NEWPAGE = 6
  571. UPDN_STATE_DISABLED = 7
  572.  
  573. UPDN_STATE_STR = {UPDN_STATE_IDLE: "Idle",
  574.                   UPDN_STATE_REQSTART: "Request start",
  575.                   UPDN_STATE_XFERACTIVE: "Transfer active",
  576.                   UPDN_STATE_ERRORABORT: "Error abort",
  577.                   UPDN_STATE_XFERDONE: "Transfer done",
  578.                   UPDN_STATE_NEWPAGE: "New page",
  579.                   UPDN_STATE_DISABLED: "Disabled",}
  580.  
  581. # Fax download errors (taken from doc/Fax/WindowsFax/sdcore/DevIO/DevIODefs.h)
  582. #
  583. DN_ERROR_NONE = 0
  584. DN_ERROR_HOST_ABORT = 705
  585. DN_ERROR_STOP_KEY_PRESSED = 706
  586. DN_ERROR_SESSION_FAIL = 709
  587. DN_ERROR_TX_ERROR = 710
  588. DN_ERROR_PHONE_UNAVAILABLE = 711
  589. DN_ERROR_OUT_OF_MEMORY = 713
  590. DN_ERROR_RESULT_BUSY = 714
  591. DN_ERROR_NO_ANSWER = 715
  592. DN_ERROR_NO_DIAL_TONE = 716
  593. DN_ERROR_DOC_JAM = 717
  594. DN_ERROR_DOOR_OPEN = 718
  595. DN_ERROR_POWER_FAILED = 719
  596. DN_ERROR_BLACKLIST = 720
  597. DN_ERROR_DOC_STORAGE_FULL = 721
  598. DN_ERROR_RESULT_COLOR_UNSUP = 722
  599. DN_ERROR_UNKNOWN = 9999
  600.  
  601. DN_ERROR_STR = {DN_ERROR_NONE: "None",
  602.                 DN_ERROR_HOST_ABORT: "Host aborted",
  603.                 DN_ERROR_STOP_KEY_PRESSED: "Stop key pressed",
  604.                 DN_ERROR_SESSION_FAIL: "Session failed",
  605.                 DN_ERROR_TX_ERROR: "Transmit error",
  606.                 DN_ERROR_PHONE_UNAVAILABLE: "Phone unavailable",
  607.                 DN_ERROR_OUT_OF_MEMORY: "Out of memory",
  608.                 DN_ERROR_RESULT_BUSY: "Result busy",
  609.                 DN_ERROR_NO_ANSWER: "No answer",
  610.                 DN_ERROR_NO_DIAL_TONE: "No dial tone",
  611.                 DN_ERROR_DOC_JAM: "Document jammed",
  612.                 DN_ERROR_DOOR_OPEN: "Door open",
  613.                 DN_ERROR_POWER_FAILED: "Power failed",
  614.                 DN_ERROR_BLACKLIST: "Blacklisted",
  615.                 DN_ERROR_DOC_STORAGE_FULL: "Document storage full",
  616.                 DN_ERROR_RESULT_COLOR_UNSUP: "Color unsupported",
  617.                 DN_ERROR_UNKNOWN: "Unknown error"}
  618.  
  619. OID_FAX_TOKEN = ('1.1.1.27', TYPE_BINARY)
  620.  
  621. OID_FAX_TX_ID = ('1.1.6.3.2.3', TYPE_SIGNED_INTEGER)
  622. OID_FAXJOB_TX_ERROR = ('1.1.6.3.3.4.1', TYPE_SIGNED_INTEGER)
  623.  
  624. OID_FAX_LOCAL_PHONE_NUM = ('1.1.3.8', TYPE_STRING)
  625. OID_FAX_STATION_NAME = ('1.1.3.9', TYPE_STRING)
  626. OID_FAX_LINE_TYPE = ('1.3.7.1.16', TYPE_ENUMERATION)
  627. OID_FAX_ANSWERMODE = ('1.1.9.2.1.1', TYPE_ENUMERATION)
  628. OID_FAX_RING_ENABLE = ('1.3.7.1.8', TYPE_ENUMERATION)
  629. OID_FAX_NUM_RINGS_PICKUP = ('1.1.9.2.1.2', TYPE_SIGNED_INTEGER)
  630. OID_FAX_MIN_RINGS_PICKUP = ('1.3.7.2.2', TYPE_SIGNED_INTEGER)
  631. OID_FAX_MAX_RINGS_PICKUP = ('1.3.7.2.3', TYPE_SIGNED_INTEGER)
  632. OID_FAX_RING_TYPE_PICKUP = ('1.1.9.2.1.3', TYPE_COLLECTION)
  633. OID_FAX_DIAL_MODE = ('1.1.9.1.1.1', TYPE_ENUMERATION)
  634. OID_FAX_ALLOW_REDIALS = ('1.4.2.5.3', TYPE_ENUMERATION)
  635. OID_FAX_REDIAL = ('1.1.9.1.1.2', TYPE_COLLECTION)
  636. OID_FAX_RESOLUTION = ('1.4.2.1.1', TYPE_BINARY)
  637. OID_FAX_CONTRAST = ('1.4.2.1.2', TYPE_SIGNED_INTEGER)
  638.  
  639. #OID_FAX_UPLOAD = ('1.3.7.2.1', TYPE_ENUMERATION)
  640. #OID_FAX_UPLOAD_ERROR = ('1.3.7.2.7', TYPE_SIGNED_INTEGER)
  641.  
  642. OID_FAX_CFG_UPLOAD_DATA_TYPE = ('1.1.1.14', TYPE_ENUMERATION)
  643. FAX_CFG_UPLOAD_DATA_TYPE_SPEEDDIALS = 5
  644. FAX_CFG_UPLOAD_DATA_TYPE_FAXLOGS = 6
  645. FAX_CFG_UPLOAD_DATA_TYPE_CONFIG_PARAMS = 7
  646. FAX_CFG_UPLOAD_DATA_TYPE_JUNK_FAX_DIAL_STRINGS = 8
  647.  
  648. OID_UPLOAD_TIMEOUT = ('1.1.1.18', TYPE_SIGNED_INTEGER)
  649. DEFAULT_UPLOAD_TIMEOUT = 60
  650.  
  651. OID_DEVICE_CFG_UPLOAD = ('1.1.1.13', TYPE_ENUMERATION)
  652.  
  653. #
  654. # Copier
  655. #
  656.  
  657. OID_COPIER_TOKEN = ('1.1.1.24', TYPE_BINARY)
  658. OID_COPY_SCANNER_DIMENSIONS = ('1.2.2.2.13', TYPE_STRING)
  659.  
  660. # Sticky settings
  661. OID_COPIER_CONTRAST = ('1.5.1.2', TYPE_SIGNED_INTEGER) # -125, -100, -75, -50, -25, 0, 25, 50, 75, 100, 125
  662. OID_COPIER_REDUCTION = ('1.5.1.4', TYPE_SIGNED_INTEGER) # (100%=no scaling) (OID_COPIER_FIT_TO_PAGE overrides)
  663.                                                         # range: COPIER-REDUCTION-MAXIMUM (25) - COPIER-ENLARGEMENT-MAXIMUM (400)
  664. OID_COPIER_NUM_COPIES = ('1.5.1.6', TYPE_SIGNED_INTEGER) # 1-99
  665.  
  666. OID_COPIER_COLLATION = ('1.5.1.7', TYPE_ENUMERATION)
  667. COPIER_COLLATION_DISABLED = 1
  668. COPIER_COLLATION_FORWARD = 2
  669.  
  670. OID_COPIER_ENLARGEMENT_MAXIMUM = ('1.5.1.11', TYPE_SIGNED_INTEGER) # default 400
  671. OID_COPIER_REDUCTION_MAXIMUM = ('1.5.1.12', TYPE_SIGNED_INTEGER) # default 25
  672.  
  673. OID_COPIER_QUALITY = ('1.5.1.13', TYPE_ENUMERATION)
  674. COPIER_QUALITY_FAST = 1
  675. COPIER_QUALITY_NORMAL = 2
  676. COPIER_QUALITY_PRESENTATION = 3
  677. COPIER_QUALITY_DRAFT = 4
  678. COPIER_QUALITY_BEST = 5
  679.  
  680. OID_COPIER_ADF_PAGE_COUNT = ('1.5.1.19', TYPE_SIGNED_INTEGER)
  681. OID_COPIER_PRINT_PAGE_COUNT = ('1.5.1.20', TYPE_SIGNED_INTEGER)
  682.  
  683. OID_COPIER_FIT_TO_PAGE = ('1.5.1.47', TYPE_ENUMERATION)
  684. COPIER_FIT_TO_PAGE_DISABLED = 1
  685. COPIER_FIT_TO_PAGE_ENABLED = 2
  686.  
  687. # Job (non-sticky) settings
  688. OID_COPIER_JOB_QUALITY = ('1.5.1.22', TYPE_ENUMERATION)
  689. # use enums from OID_COPIER_QUALITY
  690.  
  691. OID_COPIER_JOB_MEDIA_SIZE = ('1.5.1.21', TYPE_ENUMERATION)
  692. COPIER_JOB_MEDIA_SIZE_US_LETTER = 2
  693. COPIER_JOB_MEDIA_SIZE_US_LEGAL = 3
  694. COPIER_JOB_MEDIA_SIZE_A4 = 26
  695.  
  696. OID_COPIER_JOB_COLLATION = ('1.5.1.23', TYPE_ENUMERATION)
  697. # use enums from OID_COPIER_COLLATION
  698.  
  699. OID_COPIER_JOB_NUM_COPIES = ('1.5.1.24', TYPE_SIGNED_INTEGER)
  700. OID_COPIER_JOB_REDUCTION = ('1.5.1.25', TYPE_SIGNED_INTEGER)
  701. OID_COPIER_JOB_CONTRAST = ('1.5.1.26', TYPE_SIGNED_INTEGER) # -125, -100, -75, -50, -25, 0, 25, 50, 75, 100, 125
  702.  
  703. OID_COPIER_JOB_FIT_TO_PAGE = ('1.5.1.48', TYPE_ENUMERATION)
  704. # use enums from OID_COPIER_FIT_TO_PAGE
  705.  
  706. # Copy job
  707.  
  708. OID_COPIER_JOB = ('1.5.1.27', TYPE_ENUMERATION)
  709. COPIER_JOB_IDLE = 1
  710. COPIER_JOB_START = 2
  711. COPIER_JOB_ACTIVE = 3
  712. COPIER_JOB_ABORTING = 4
  713. COPIER_JOB_SETUP = 5
  714.  
  715. # AiO Specific Copy
  716.  
  717. OID_COLOR_COPY_REQUEST = ('1.5.1.8', TYPE_ENUMERATION)
  718. OID_SCAN_TO_PRINTER = ('1.5.1.5', TYPE_SIGNED_INTEGER)
  719. SCAN_TO_PRINTER_IDLE         = 1
  720. SCAN_TO_PRINTER_START        = 2
  721. SCAN_TO_PRINTER_ACTIVE       = 3
  722. SCAN_TO_PRINTER_ABORTED      = 4
  723. SCAN_TO_PRINTER_SET_DEFAULTS = 5
  724. SCAN_TO_PRINTER_GET_DEFAULTS = 6
  725.  
  726. OID_PIXEL_DATA_TYPE = ('1.5.1.3', TYPE_SIGNED_INTEGER)
  727. PIXEL_DATA_TYPE_GRAYSCALE_256     = 8
  728. PIXEL_DATA_TYPE_COLOR_24_BIT      = 24
  729.  
  730. OID_COPIER_SPECIAL_FEATURES = ('1.5.1.16', TYPE_SIGNED_INTEGER)
  731. COPY_FEATURE_NONE     = 1
  732. COPY_FEATURE_CLONE    = 2
  733. COPY_FEATURE_POSTER   = 3
  734. COPY_FEATURE_MIRROR   = 4
  735. COPY_FEATURE_AUTOFIT  = 5
  736. COPY_FEATURE_TWOUP    = 6
  737. COPY_FEATURE_AUTOFILL = 7
  738.  
  739.  
  740. OID_COPIER_PHOTO_MODE = ('1.5.1.15', TYPE_COLLECTION)
  741. ENHANCE_LIGHT_COLORS  =  0x00000001  # Bit  0
  742. ENHANCE_TEXT          =  0x00000002  # Bit  1
  743.  
  744. OID_COPIER_NUM_COPIES_AIO = ('1.5.1.6', TYPE_SIGNED_INTEGER)
  745. OID_COPIER_CONTRAST_AIO = ('1.5.1.2', TYPE_SIGNED_INTEGER)
  746. OID_COPIER_REDUCTION_AIO = ('1.5.1.4', TYPE_SIGNED_INTEGER)
  747. OID_COPIER_QUALITY_AIO = ('1.5.1.13', TYPE_ENUMERATION)
  748.  
  749. OID_COPIER_JOB_INPUT_TRAY_SELECT = ('1.5.1.51', TYPE_SIGNED_INTEGER)
  750. COPIER_JOB_INPUT_TRAY_1 = 1
  751. COPIER_JOB_INPUT_TRAY_2 = 1
  752. COPIER_JOB_INPUT_TRAY_3 = 1
  753.  
  754. OID_COPIER_MEDIA_TYPE = ('1.5.1.14', TYPE_SIGNED_INTEGER)
  755. COPIER_MEDIA_TYPE_PLAIN               = 1
  756. COPIER_MEDIA_TYPE_BRIGHT_WHITE        = 2
  757. COPIER_MEDIA_TYPE_PREMIUM_PHOTO       = 3
  758. COPIER_MEDIA_TYPE_SPECIAL             = 4
  759. COPIER_MEDIA_TYPE_TRANSPARENCY        = 5
  760. COPIER_MEDIA_TYPE_IRON_ON             = 6
  761. COPIER_MEDIA_TYPE_FAST_TRANSPARANCEY  = 7
  762. COPIER_MEDIA_TYPE_BROCHURE_MATTE      = 8
  763. COPIER_MEDIA_TYPE_BROCHURE_GLOSSY     = 9
  764. COPIER_MEDIA_TYPE_PHOTO_GLOSSY        = 10
  765. COPIER_MEDIA_TYPE_MATTE_PAPER         = 11
  766. COPIER_MEDIA_TYPE_EVERYDAY_PHOTO      = 12
  767. COPIER_MEDIA_TYPE_PHOTO_QUAL_INKJET   = 13
  768. COPIER_MEDIA_TYPE_PHOTO               = 14
  769. COPIER_MEDIA_TYPE_AUTOMATIC           = 15
  770. COPIER_MEDIA_TYPE_ADVANCED_PHOTO      = 16
  771. COPIER_MEDIA_TYPE_IRON_ON_MIRRORED    = 17
  772.  
  773.  
  774.  
  775. # Misc
  776.  
  777. OID_DATE_AND_TIME = ('1.1.2.17', TYPE_BINARY)
  778.  
  779.  
  780.  
  781.